package com.example.mvp_demo.moudle;

import com.example.mvp_demo.data.Phone;

import java.util.ArrayList;

/**
 * Created by Administrator on 2017/3/23.
 * 处理与数据相关的一些操作
 *
 * 手机工厂类
 */
//TODO moudle层 处理与数据相关的一些操作
public class PhoneFactory {
    //创建集合
    private ArrayList<Phone> phoneList = new ArrayList<>();

    //添加手机,将手机添加到集合中
    public void addPhone (Phone phone){
        phoneList.add(phone);
    }

    public void removePhone(Phone phone){
        phoneList.remove(phone);
    }

    public void removePhone(int index){
        if (index>=0 && index < phoneList.size()){
            phoneList.remove(index);
        }
    }

    public void createPhone(String name,double price){
        Phone phone = new Phone(name,price);
        phoneList.add(phone);
    }

    public ArrayList<Phone> getPhoneList(){
        return phoneList;
    }

    public int getPhoneCount(){
        return phoneList.size();
    }
}
